Overview
DevolutionSync includes production-ready Docker configuration for containerized deployment. This approach ensures consistent environments across development, staging, and production systems.Prerequisites
Docker Engine
Version 20.10 or higher
Docker Compose
Version 2.0 or higher
MySQL Server
Version 8.0 (external or containerized)
Network Access
Port 8097 available for web access
Installation
- Linux
- macOS
- Windows
Dockerfile Breakdown
TheDockerfile defines the container image for DevolutionSync:
Dockerfile
Dockerfile Components
Base Image: php:8.2-apache
Base Image: php:8.2-apache
- PHP 8.2 runtime
- Apache 2.4 web server
- Debian-based Linux
- Pre-configured for web applications
This base image includes mod_rewrite and other essential Apache modules.
PHP Extensions
PHP Extensions
| Extension | Purpose |
|---|---|
pdo | PHP Data Objects - database abstraction layer |
pdo_mysql | MySQL driver for PDO |
mysqli | MySQL Improved extension (legacy support) |
Application Files
Application Files
- PHP source code
- Controllers, Models, Views
- Configuration files
- Static assets (CSS, JS, images)
- Upload directories
File Permissions
File Permissions
- Owner:
www-data(Apache user) - Group:
www-data - Permissions:
755(rwxr-xr-x)- Owner: Read, Write, Execute
- Group: Read, Execute
- Others: Read, Execute
Port Exposure
Port Exposure
Docker Compose Configuration
TheDocker-compose.yml orchestrates the application container and its dependencies:
Docker-compose.yml
Configuration Breakdown
- Web Service
- Port Mapping
- Volume Mounts
- Networks
| Setting | Value | Description |
|---|---|---|
build.context | . | Build from current directory |
build.dockerfile | Dockerfile | Use specified Dockerfile |
container_name | Proyecto_UCP | Container name for easy reference |
ports | 8097:80 | Map host:container ports |
volumes | ./:/var/www/html | Mount project directory |
networks | red_local | Connect to custom network |
Database Configuration (Commented)
The current configuration uses an external MySQL database:Adding MySQL Container (Optional)
Adding MySQL Container (Optional)
To run MySQL in Docker, uncomment and add:Update
Docker-compose.yml
config/conexion.php:Deployment Steps
Quick Start
Detailed Deployment
Environment Variables
For production, use environment variables instead of hardcoded credentials:Create .env File
.env
Update docker-compose.yml
Docker-compose.yml
Update config/conexion.php
config/conexion.php
Container Management
Common Commands
Execute Commands in Container
Execute Commands in Container
File Operations
File Operations
Debugging
Debugging
Restart Services
Restart Services
Production Optimization
Dockerfile for Production
Dockerfile.prod
Production docker-compose.yml
docker-compose.prod.yml
Security Best Practices
Use Non-Root User
Scan for Vulnerabilities
Use Secrets
Limit Resources
Monitoring and Logging
Log Configuration
docker-compose.yml
Health Checks
docker-compose.yml
Troubleshooting
Port Already in Use
Port Already in Use
Error:
Bind for 0.0.0.0:8097 failed: port is already allocatedSolution:Database Connection Failed
Database Connection Failed
Error:
Connection refused or Access deniedSolution:Permission Denied Errors
Permission Denied Errors
Error:
Permission denied when uploading filesSolution:Container Keeps Restarting
Container Keeps Restarting
Solution:
Backup and Recovery
Backup Container Data
Restore from Backup
Next Steps
Architecture
Understand system architecture
Database Schema
Learn database structure
Configuration
Configure environment settings
Monitoring
Set up monitoring and alerts